import Vue from 'vue'
import App from './App.vue'
import './registerServiceWorker'
import router from './router'
import store from './store'

// 引入mock
require('@/mock/mock')

// 引入axios
import axios from "axios";
Vue.prototype.$axios = axios

// 引入element
import 'element-ui/lib/theme-chalk/index.css'

import {
  Pagination,
  Dialog,
  Dropdown,
  DropdownMenu,
  DropdownItem,
  Menu,
  Submenu,
  MenuItem,
  MenuItemGroup,
  Input,
  InputNumber,
  Select,
  Option,
  OptionGroup,
  Button,
  ButtonGroup,
  Table,
  TableColumn,
  DatePicker,
  Form,
  FormItem,
  Slider,
  Icon,
  Container,
  Header,
  Aside,
  Main,
  Footer,
  Card,
  Col,
  Row,
  Progress,
  Avatar,
  Tabs,
  TabPane,
  Upload,
  Loading,
  MessageBox,
  Message
} from 'element-ui';

Vue.use(Pagination);
Vue.use(Dialog);
Vue.use(Dropdown);
Vue.use(DropdownMenu);
Vue.use(DropdownItem);
Vue.use(Menu);
Vue.use(Submenu);
Vue.use(MenuItem);
Vue.use(MenuItemGroup);
Vue.use(Input);
Vue.use(InputNumber);
Vue.use(Select);
Vue.use(Option);
Vue.use(OptionGroup);
Vue.use(Button);
Vue.use(ButtonGroup);
Vue.use(Table);
Vue.use(TableColumn);
Vue.use(DatePicker);
Vue.use(Form);
Vue.use(FormItem);
Vue.use(Slider);
Vue.use(Icon);
Vue.use(Container);
Vue.use(Header);
Vue.use(Aside);
Vue.use(Main);
Vue.use(Footer);
Vue.use(Card);
Vue.use(Col);
Vue.use(Row);
Vue.use(Progress);
Vue.use(Avatar);
Vue.use(Tabs);
Vue.use(TabPane);
Vue.use(Upload);

Vue.use(Loading.directive);

Vue.prototype.$loading = Loading.service;
Vue.prototype.$msgbox = MessageBox;
Vue.prototype.$alert = MessageBox.alert;
Vue.prototype.$confirm = MessageBox.confirm;
Vue.prototype.$message = Message;

// 引入接口地址和请求方法
import address from '@/filters/address'
Vue.prototype.$address = address;
import {LOGIN,POST,GET,REGISTER,SEND} from "@/filters/api";
Vue.prototype.$login = LOGIN;
Vue.prototype.$post = POST;
Vue.prototype.$get = GET;
Vue.prototype.$register = REGISTER;
Vue.prototype.$send = SEND;

// 引入复制方法
import Clipboard from 'vue-clipboard2'
Vue.use(Clipboard)

// 语言切换
import VueI18n from "vue-i18n";
import ens from 'element-ui/lib/locale/lang/en'
import rus from 'element-ui/lib/locale/lang/ru-RU'
Vue.use(VueI18n)
const messages = {
  'en': {
    ...require('@/assets/lang/en.json'),
    ...ens
  },
  'rus': {
    ...require('@/assets/lang/rus.json'),
    ...rus
  }
}
console.log(store.getters.getLang)
const i18n = new VueI18n({
  locale: store.getters.getLang,
  messages
})

// element 切换语言
import ElementLocale from 'element-ui/lib/locale'
ElementLocale.i18n((key, value) => i18n.t(key, value))

Vue.config.productionTip = false

new Vue({
  router,
  store,
  i18n,
  render: h => h(App)
}).$mount('#app')
